﻿/// /////////////////////////////////////////////
// 单元名 : PrjDepInfo
// 作者 : Hawk
// 单元描述 :
// 日期 : 2023-09-15
/// /////////////////////////////////////////////

{$IFDEF FPC}
{$H+}
{$MODE DELPHI}
{$ENDIF}
unit PrjDepInfo;

interface

uses
{$IFnDEF FPC}
  Windows,
{$ELSE}
  LCLIntf, LCLType, LMessages,
{$ENDIF}
  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BaseDialog, StdCtrls, Buttons,
  ExtCtrls, unitCommonDataStruct, unitClientUpdateSvrObj;

type
  TdlgProjectDeployInfo = class(TdlgBase)
    GroupBox1: TGroupBox;
    eDeployPath: TEdit;
    m: TMemo;
    eProjectName: TEdit;
    Label3: TLabel;
    eProjectID: TEdit;
    procedure btnOKClick(Sender: TObject);
  private
    { Private declarations }
  protected
    function BindObjCls: TSerialObjClass; override;
    procedure DoObjToUI; override;
    procedure DoUIToObj; override;
  public
    { Public declarations }
  end;

implementation

uses unitClientUpdateObj;

{$IFnDEF FPC}
  {$R *.dfm}
{$ELSE}
  {$R *.lfm}
{$ENDIF}

function TdlgProjectDeployInfo.BindObjCls: TSerialObjClass;
begin
  Result := TUpdateableProject;
end;

procedure TdlgProjectDeployInfo.btnOKClick(Sender: TObject);
begin
  if Trim(eProjectName.Text) = '' then
  begin
    ShowErrorMsg('请指定项目名称', []);
    eProjectName.SetFocus;
    Exit;
  end;
  if Trim(eDeployPath.Text) = '' then
  begin
    ShowErrorMsg('请指定部署路径', []);
    eDeployPath.SetFocus;
    Exit;
  end;
  ModalResult := mrOK;
end;

procedure TdlgProjectDeployInfo.DoObjToUI;
var
  prj: TUpdateableProject;
begin
  prj := TUpdateableProject(Obj);
  if not prj.ObjID.IsEmpty then
    eProjectID.Text := prj.ObjID.ToString;
  eDeployPath.Text := prj.DeployPath;
  eProjectName.Text := prj.Caption;
end;

procedure TdlgProjectDeployInfo.DoUIToObj;
var
  prj: TUpdateableProject;
begin
  prj := TUpdateableProject(Obj);
  prj.Caption := Trim(eProjectName.Text);
  prj.DeployPath := Trim(eDeployPath.Text);
end;

end.
